#!/usr/bin/python3
import numpy as np
import pandas as pd
import tushare as ts
import json
import matplotlib.pyplot as plt

from sqlalchemy import create_engine
print(ts.__version__)
pro = ts.pro_api('ea3263c5424f08c3e04d605af9458cfc349613d5b7c27e99994eb396')

holdings={
    "格力电器":"000651.sz",
    "伊利股份":"600887.sh",
    "中国银行":"601988.sh",
    "光大银行":"601818.sh",
    "万科A":"000002.sz",
    "东方财富":"300059.sz",
    "乐普医疗":"300003.sz",
    "奕东电子":"301123.sz"
}

hostname="10.120.100.18"
db="stock"
username="stock"
password="Holdings!23"



# Create SQLAlchemy engine to connect to MySQL Database
engine = create_engine("mysql+pymysql://{user}:{password}@{host}/{database}".
                       format(host=hostname, database=db, user=username, password=password))

data = pro.query('stock_basic', exchange='', list_status='L', fields='ts_code,exchange,market,symbol,name,area,industry,list_date,list_status,delist_date,is_hs')
data.to_sql('stock_basic', engine, if_exists='replace', index=False)